package com.hsnn.medstgmini.sys.controller;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.hsnn.medstgmini.Constants;
import com.hsnn.medstgmini.pro.project.model.BidProject;
import com.hsnn.medstgmini.pro.project.service.BidProjectManager;
import com.hsnn.medstgmini.sys.model.BidProjNotice;
import com.hsnn.medstgmini.sys.model.SysNotice;
import com.hsnn.medstgmini.sys.model.SysNoticeLog;
import com.hsnn.medstgmini.sys.model.SysUser;
import com.hsnn.medstgmini.sys.service.SysNoticeManager;
import com.hsnn.medstgmini.util.DateUtil;
import com.hsnn.medstgmini.util.Pagination;
import com.hsnn.medstgmini.util.ParseDate;

@Controller
@RequestMapping("/sysNotice")
public class SysNoticeController {

	@Autowired
	private SysNoticeManager sysNoticeManager;
	
	@Autowired
	private BidProjectManager bidProjectManager;
	
	@Autowired
	private HttpServletRequest request;
	
	private static final Logger log = Logger
			.getLogger(SysNoticeController.class);
	/**
	 * @category 跳转到公告列表
	 * @author zhouqi
	 * @date 2015年9月29日09:08:14
	 * @param void
	 * @return String
	 */
	@RequestMapping("/toSysNoticeList")
	public String toSysNoticList(Model model){
		List<BidProject> projectList = sysNoticeManager.getProjectList();
		model.addAttribute("projectList", projectList);
		SysUser user=(SysUser) request.getSession().getAttribute(Constants.USERINFO);
		String projId = request.getParameter("projId");
		if(StringUtils.isNotBlank(user.getDefaultProjId())){
			model.addAttribute("defaultProjId",user.getDefaultProjId());
			BidProject bidProject = bidProjectManager.getBidProjectById(user.getDefaultProjId());
			model.addAttribute("bidProject",bidProject);
		}
		if(StringUtils.isNotBlank(projId)){
			model.addAttribute("projId",projId);
			BidProject bidProject = bidProjectManager.getBidProjectById(projId);
			model.addAttribute("bidProject",bidProject);
			return "/sys/sysNoticeList"; 
		}
		if(StringUtils.isBlank(user.getDefaultProjId())){
			return "/sys/sysNoticeSwtich";
		}else{
			model.addAttribute("projId", user.getDefaultProjId());
			BidProject bidProject = bidProjectManager.getBidProjectById(projId);
			model.addAttribute("bidProject",bidProject);
		}
		return "/sys/sysNoticeList";
	}
	
	/**
	 * @category 获取公告列表
	 * @author zhouqi
	 * @date 2015年8月21日09:14:59
	 * @param void
	 * @return Pagination
	 */
	@RequestMapping("/getSysNoticeList")
	@ResponseBody
	public Pagination getSysNoticeList(){
		Pagination page = new Pagination(request);
		String title = request.getParameter("sysNoticeTitle");
		String status = request.getParameter("status");
		String startPoint = request.getParameter("startPoint");
		String endPoint = request.getParameter("endPoint");
		String projId = request.getParameter("projId");
		
		page.getConditions().put("title", title);
		page.getConditions().put("status", status);
		page.getConditions().put("startPoint", startPoint);
		page.getConditions().put("endPoint", endPoint);
		page.getConditions().put("projId", projId);
		
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		if(StringUtils.isNotBlank(user.getDefaultProjId())){
			page.getConditions().put("projId",user.getDefaultProjId());
		}
		
		try{
		    page = sysNoticeManager.getSysNoticeList(page);
		    page.setSuccess(true);
		}catch(Exception e){
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 跳转到编辑|新增页面
	 * @author zhouqi
	 * @date 2015年8月21日09:14:59
	 * @param void
	 * @return Pagination
	 */
	@RequestMapping("/toEditSysNotice")
	public String toEditSysNotice(Model model){
		String sysNoticeId = request.getParameter("sysNoticeId");
		String projId = request.getParameter("projId");
		SysNotice sysNotice = new SysNotice();
		BidProjNotice bidProjSysNotice = sysNoticeManager.getBidProjNoticeById(sysNoticeId);//项目公告关系
		List<BidProject> projectList = sysNoticeManager.getProjectList();
		model.addAttribute("projectList", projectList);
		String opType = request.getParameter("opType");
		if(StringUtils.isNotBlank(sysNoticeId)){
			sysNotice = sysNoticeManager.getSysNoticeById(sysNoticeId);
			String dateTime = DateUtil.dateTime(sysNotice.getDateTime());
			model.addAttribute("sysNotice",sysNotice);
			model.addAttribute("dateTime",dateTime);
		}
		model.addAttribute("opType",opType);
		model.addAttribute("projectList",projectList);
		model.addAttribute("projId",projId);
		model.addAttribute("bidProjSysNotice",bidProjSysNotice);
		return "/sys/editSysNotice";
	}
	
	/**
	 * @category 保存或新增公告
	 * @author zhouqi
	 * @date 2015年8月23日10:44:07
	 * @param Pagination
	 * @return Pagination
	 */
	@RequestMapping("toSaveOrEditeSysNotice")
	@ResponseBody
	public Pagination saveOrEditSysNotice(SysNotice sysNotice,BidProjNotice bidProjNotice){
		Pagination page = new Pagination();
		String projectId = request.getParameter("projectId");
		try {
			//日期转换
			String dateTimeS = request.getParameter("dateTime");
			if(StringUtils.isNotBlank(dateTimeS)){
		    	Date dateTime = DateUtil.parseDateTime(dateTimeS);
		    	Timestamp dateTimestamp = DateUtil.getTimeStamp(dateTime);
		    	sysNotice.setDateTime(dateTimestamp);
			}
			String sysNoticeId = sysNotice.getSysNoticeId();
			SysUser user=(SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if(StringUtils.isBlank(sysNoticeId)){//新增
				sysNotice.setSysNoticeId(UUID.randomUUID().toString());
				sysNotice.setSysNoticeCode(UUID.randomUUID().toString());//code的生成规则	
				sysNotice.setStatus(0);//0未发布
				if(StringUtils.isBlank(bidProjNotice.getProjSysNoticeId())){//设置项目公告关系
					bidProjNotice.setProjId(projectId);
					bidProjNotice.setProjSysNoticeId(UUID.randomUUID().toString());
					bidProjNotice.setSysNoticeId(sysNotice.getSysNoticeId());
					bidProjNotice.setStatus(1);
					bidProjNotice.setUpdDateTime(DateUtil.getTimeStamp());
					bidProjNotice.setUpdUser(user.getName());
					sysNoticeManager.saveOrUpdBidProjNotice(bidProjNotice);
					sysNoticeManager.writeLogOfProjNotice(bidProjNotice);//项目公告关联日志
				}
				sysNoticeManager.saveSysNotice(sysNotice);
			}
			if(StringUtils.isNotBlank(sysNoticeId)){//编辑
				int status = sysNoticeManager.getSysNoticeById(sysNoticeId).getStatus();
				sysNotice.setStatus(status);
				if(StringUtils.isNotBlank(bidProjNotice.getProjSysNoticeId())){//设置项目公告关系
					bidProjNotice.setProjId(projectId);
					bidProjNotice.setSysNoticeId(sysNotice.getSysNoticeId());
					bidProjNotice.setStatus(1);
					bidProjNotice.setUpdDateTime(DateUtil.getTimeStamp());
					bidProjNotice.setUpdUser(user.getName());
					sysNoticeManager.saveOrUpdBidProjNotice(bidProjNotice);
					sysNoticeManager.writeLogOfProjNotice(bidProjNotice);
				}
				sysNoticeManager.updateSysNotice(sysNotice);
			}
			sysNotice.setUpdDateTime(DateUtil.getTimeStamp());
			sysNotice.setUpdUser(user.getName());
			sysNoticeManager.writeLog(sysNotice);//写日志
			page.setSuccess(true);
			page.setMsg("保存成功");
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
			page.setMsg("保存失败");
		}
		return page;
	}
	
	/**
	 * @category 跳转到维护记录页面
	 * @author zhouqi
	 * @date 2015年8月21日09:14:59
	 * @param void
	 * @return Pagination
	 */
	@RequestMapping("toSysNoticeLogList")
	public String toSysNoticeLogList(Model model){
		String sysNoticeId = request.getParameter("sysNoticeId");
		String projId = request.getParameter("projId");
		if(StringUtils.isNotBlank(sysNoticeId)){
			model.addAttribute("sysNoticeId",sysNoticeId);
		}
		if(StringUtils.isNotBlank(projId)){
			model.addAttribute("projId",projId);
		}
		return "/sys/sysNoticeLogList";
	}
	/**
	 * @category 跳转维护记录详情页面
	 * @author zhouqi
	 * @date 2015年8月21日09:14:59
	 * @param void
	 * @return String
	 */
	@RequestMapping("toSysNoticeLogDetail")
	public String toNoticeDetailList(Model model){
		String sysNoticeId = request.getParameter("sysNoticeId");
		String updDateTime = request.getParameter("updDateTime");
		String projId = request.getParameter("projId");
		List<SysNoticeLog> list = sysNoticeManager.getCompareLog(sysNoticeId, updDateTime);
		SysNoticeLog oldSysNoticeLog = new SysNoticeLog();
		SysNoticeLog newSysNoticeLog = new SysNoticeLog();
		if(list.size()==0){
			return "/sys/sysNoticeLogDetail";
		}
		if(list.size()==1){
			oldSysNoticeLog = list.get(0);
			newSysNoticeLog = list.get(0);
		}
		if(list.size()>1){
			newSysNoticeLog = list.get(0);
			oldSysNoticeLog = list.get(1);
			
		}
		String oldStatus = oldSysNoticeLog.getStatus()==0?"未发布":"发布";
		String newStatus = newSysNoticeLog.getStatus()==0?"未发布":"发布";
		String oldUpdDatetime = DateUtil.dateTime(oldSysNoticeLog.getUpdDateTime());
		String newUpdDatetime = DateUtil.dateTime(newSysNoticeLog.getUpdDateTime());
		String newDatetime = DateUtil.dateTime(newSysNoticeLog.getDateTime());
		String oldDatetime = DateUtil.dateTime(oldSysNoticeLog.getDateTime());
		model.addAttribute("oldUpdDatetime", oldUpdDatetime);
		model.addAttribute("newUpdDatetime", newUpdDatetime);
		model.addAttribute("newDatetime", newDatetime);
		model.addAttribute("oldDatetime", oldDatetime);
		model.addAttribute("newSysNoticeLog", newSysNoticeLog);
		model.addAttribute("oldSysNoticeLog", oldSysNoticeLog);
		model.addAttribute("oldStatus", oldStatus);
		model.addAttribute("newStatus", newStatus);
		model.addAttribute("projId",projId);
		return "/sys/sysNoticeLogDetail";
	}
	/**
	 * @category 获取维护记录列表
	 * @author zhouqi
	 * @date 2015年8月21日09:14:59
	 * @param void
	 * @return Pagination
	 */
	@RequestMapping("getSysNoticeLogList")
	@ResponseBody
	public Pagination getSysNoticeLogList(Pagination page){
		String sysNoticeId = request.getParameter("sysNoticeId");
	    String startPoint = request.getParameter("startPoint");
	    String endPoint = request.getParameter("endPoint");
	    if(StringUtils.isNoneBlank(startPoint)){
	    	page.getConditions().put("startPoint", startPoint);
	    }
	    if(StringUtils.isNoneBlank(endPoint)){
	    	page.getConditions().put("endPoint", endPoint);
	    }
	    if(StringUtils.isNoneBlank(sysNoticeId)){
	    	page.getConditions().put("sysNoticeId", sysNoticeId);
	    }
	    try{
	    	sysNoticeManager.getSysNoticeLogList(page);
	    	page.setSuccess(true);
	    }catch(Exception e){
	    	log.error("",e);
	    	page.setSuccess(false);
	    }
	    return page;
	}
	/**
	 * @category 获取维护记录详情
	 * @author zhouqi
	 * @date 2015年8月21日09:14:59
	 * @param SysNoticeLogId,model
	 * @return Pagination
	 */
	@RequestMapping("toSysNoticeLogDetial")
	public String toSysNoticeLogDetial(String sysNoticeLogId, Model model){
		SysNoticeLog sysNoticeLog = sysNoticeManager.getSysNoticeLogById(sysNoticeLogId);
		if(null != sysNoticeLog){
			model.addAttribute("sysNoticeLog",sysNoticeLog);
		}
		return "/sys/sysNoticeLogDetial";
	}
	
	/**
	 * @category 获取公告详情
	 * @author zhouqi
	 * @date 2015年8月21日09:14:59
	 * @param SysNoticeLogId,model
	 * @return Pagination
	 */
	@RequestMapping("toSysNoticeDetial")
	public String toSysNoticeDetial(String sysNoticeId, Model model){
		SysNotice sysNotice = sysNoticeManager.getSysNoticeById(sysNoticeId);
		String projId = request.getParameter("projId");
		if(null != sysNotice){
			model.addAttribute("sysNotice",sysNotice);
		}
		if(StringUtils.isNotBlank(projId)){
			model.addAttribute("projId", projId);
		}
		return "/sys/sysNoticeDetail";
	}
	
	/**
	 * @category 发布公告
	 * @author zhouqi
	 * @date 2015年8月21日09:14:59
	 * @param void
	 * @return Pagination
	 */
	@RequestMapping("releaseSysNotice")
	@ResponseBody
	public Pagination releaseSysNotice(String sysNoticeId, int status){
		Pagination page = new Pagination();
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		try{
			SysNotice sysNotice = sysNoticeManager.getSysNoticeById(sysNoticeId);
			if(null != sysNotice){
				sysNotice.setStatus(status);
				sysNotice.setUpdUser(user.getId());
				sysNotice.setUpdDateTime(DateUtil.getTimeStamp());
				sysNoticeManager.updateSysNotice(sysNotice);
				page.setSuccess(false);
			}
		}catch(Exception e){
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	/**
	 * @category 批量发布公告
	 * @author zhouqi
	 * @date 2015年8月21日09:14:59
	 * @param void
	 * @return Pagination
	 */
	@RequestMapping("batchReleaseSysNotice")
	@ResponseBody
	public Pagination batchReleaseSysNotice(String overId, String status){
		Pagination page = new Pagination();
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		String[] ids = overId.split(",");
		try{
			for(int i = 0; i< ids.length;i++){
				SysNotice sysNotice = sysNoticeManager.getSysNoticeById(ids[i]);
				if(null != sysNotice){
					sysNotice.setStatus(Integer.parseInt(status));
					sysNotice.setUpdUser(user.getId());;
					sysNotice.setUpdDateTime(DateUtil.getTimeStamp());
					sysNoticeManager.updateSysNotice(sysNotice);
					sysNoticeManager.writeLog(sysNotice);
					
				}
			}
			page.setSuccess(true);
		}catch(Exception e){
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	/**
	 * @category 验证title是否重复
	 * @date 2015年9月25日13:20:03
	 * @author zhouqi
	 * @return boolean
	 */
	@RequestMapping("valitdateTitle")
	@ResponseBody
	public String validateTitle(){
		String title  = request.getParameter("title");
		List<SysNotice> list = sysNoticeManager.getSysNoticeByTitle(title.trim());
		if(list.size() > 0){
			return JSON.toJSONString(false);
		}
		return JSON.toJSONString(true);
	}
	
	/**
	 * @category 跳转到中心公告管理
	 * @author 韩守松
	 * @date   2015年11月16日
	 * @param  @return
	 */
	@RequestMapping("/toZXSysNoticeList")
	public String toZXSysNoticeList(){
		return "/sys/zx/sysZXNoticeList"; 
	}
	
	/**
	 * @category 获取中心公告数据列表
	 * @author 韩守松
	 * @date   2015年11月16日
	 * @param  @return
	 */
	@RequestMapping("/getZXSysNoticeList")
	@ResponseBody
	public Pagination getZXSysNoticeList(){
		Pagination page = new Pagination(request);
		String title = request.getParameter("sysNoticeTitle");
		String status = request.getParameter("status");
		String startPoint = request.getParameter("startPoint");
		String endPoint = request.getParameter("endPoint");
		String projId = request.getParameter("projId");
		
		page.getConditions().put("title", title);
		page.getConditions().put("startPoint", startPoint);
		page.getConditions().put("endPoint", endPoint);
		page.getConditions().put("projId", projId);
		
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		if(user.getType() == 1){
			page.getConditions().put("status", status);
		}else{
			page.getConditions().put("status", "1");
		}
		
		if(StringUtils.isNotBlank(user.getDefaultProjId())){
			page.getConditions().put("projId",user.getDefaultProjId());
		}
		
		try{
		    page = sysNoticeManager.getSysNoticeList(page);
		    page.setSuccess(true);
		}catch(Exception e){
			log.error("",e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 跳转到编辑|新增页面
	 * @author zhouqi
	 * @date 2015年8月21日09:14:59
	 * @param void
	 * @return Pagination
	 */
	@RequestMapping("/toEditZXSysNotice")
	public String toEditZXSysNotice(Model model){
		String sysNoticeId = request.getParameter("sysNoticeId");
		String projId = request.getParameter("projId");
		SysNotice sysNotice = new SysNotice();
		BidProjNotice bidProjSysNotice = sysNoticeManager.getBidProjNoticeById(sysNoticeId);//项目公告关系
		List<BidProject> projectList = sysNoticeManager.getProjectList();
		model.addAttribute("projectList", projectList);
		String opType = request.getParameter("opType");
		if(StringUtils.isNotBlank(sysNoticeId)){
			sysNotice = sysNoticeManager.getSysNoticeById(sysNoticeId);
			String dateTime = DateUtil.dateTime(sysNotice.getDateTime());
			model.addAttribute("sysNotice",sysNotice);
			model.addAttribute("dateTime",dateTime);
		}
		model.addAttribute("opType",opType);
		model.addAttribute("projectList",projectList);
		model.addAttribute("projId",projId);
		model.addAttribute("bidProjSysNotice",bidProjSysNotice);
		return "/sys/zx/editZXSysNotice";
	}
	
	/**
	 * @category 保存或新增公告
	 * @author zhouqi
	 * @date 2015年8月23日10:44:07
	 * @param Pagination
	 * @return Pagination
	 */
	@RequestMapping("toSaveOrEditeZXSysNotice")
	@ResponseBody
	public Pagination saveOrEditZXSysNotice(SysNotice sysNotice,BidProjNotice bidProjNotice){
		Pagination page = new Pagination();
		String projectId = request.getParameter("projectId");
		try {
			//日期转换
			String dateTimeS = request.getParameter("dateTime");
			if(StringUtils.isNotBlank(dateTimeS)){
		    	Date dateTime = DateUtil.parseDateTime(dateTimeS);
		    	Timestamp dateTimestamp = DateUtil.getTimeStamp(dateTime);
		    	sysNotice.setDateTime(dateTimestamp);
			}
			String sysNoticeId = sysNotice.getSysNoticeId();
			SysUser user=(SysUser) request.getSession().getAttribute(Constants.USERINFO);
			if(StringUtils.isBlank(sysNoticeId)){//新增
				sysNotice.setSysNoticeId(UUID.randomUUID().toString());
				sysNotice.setSysNoticeCode(UUID.randomUUID().toString());//code的生成规则	
				sysNotice.setStatus(0);//0未发布
				if(StringUtils.isBlank(bidProjNotice.getProjSysNoticeId())){//设置项目公告关系
					bidProjNotice.setProjId(projectId);
					bidProjNotice.setProjSysNoticeId(UUID.randomUUID().toString());
					bidProjNotice.setSysNoticeId(sysNotice.getSysNoticeId());
					bidProjNotice.setStatus(1);
					bidProjNotice.setUpdDateTime(DateUtil.getTimeStamp());
					bidProjNotice.setUpdUser(user.getName());
					sysNoticeManager.saveOrUpdBidProjNotice(bidProjNotice);
					sysNoticeManager.writeLogOfProjNotice(bidProjNotice);//项目公告关联日志
				}
				sysNoticeManager.saveSysNotice(sysNotice);
			}
			if(StringUtils.isNotBlank(sysNoticeId)){//编辑
				int status = sysNoticeManager.getSysNoticeById(sysNoticeId).getStatus();
				sysNotice.setStatus(status);
				if(StringUtils.isNotBlank(bidProjNotice.getProjSysNoticeId())){//设置项目公告关系
					bidProjNotice.setProjId(projectId);
					bidProjNotice.setSysNoticeId(sysNotice.getSysNoticeId());
					bidProjNotice.setStatus(1);
					bidProjNotice.setUpdDateTime(DateUtil.getTimeStamp());
					bidProjNotice.setUpdUser(user.getName());
					sysNoticeManager.saveOrUpdBidProjNotice(bidProjNotice);
					sysNoticeManager.writeLogOfProjNotice(bidProjNotice);
				}
				sysNoticeManager.updateSysNotice(sysNotice);
			}
			sysNotice.setUpdDateTime(DateUtil.getTimeStamp());
			sysNotice.setUpdUser(user.getName());
			sysNoticeManager.writeLog(sysNotice);//写日志
			page.setSuccess(true);
			page.setMsg("保存成功");
		} catch (Exception e) {
			log.error("",e);
			page.setSuccess(false);
			page.setMsg("保存失败");
		}
		return page;
	}
	
	/**
	 * @category 跳转到维护记录页面
	 * @author zhouqi
	 * @date 2015年8月21日09:14:59
	 * @param void
	 * @return Pagination
	 */
	@RequestMapping("toSysZXNoticeLogList")
	public String toSysZXNoticeLogList(Model model){
		String sysNoticeId = request.getParameter("sysNoticeId");
		String projId = request.getParameter("projId");
		if(StringUtils.isNotBlank(sysNoticeId)){
			model.addAttribute("sysNoticeId",sysNoticeId);
		}
		if(StringUtils.isNotBlank(projId)){
			model.addAttribute("projId",projId);
		}
		return "/sys/zx/sysZXNoticeLogList";
	}
	/**
	 * @category 跳转维护记录详情页面
	 * @author zhouqi
	 * @date 2015年8月21日09:14:59
	 * @param void
	 * @return String
	 */
	@RequestMapping("toSysZXNoticeLogDetail")
	public String toZXNoticeDetailList(Model model){
		String sysNoticeId = request.getParameter("sysNoticeId");
		String updDateTime = request.getParameter("updDateTime");
		String projId = request.getParameter("projId");
		List<SysNoticeLog> list = sysNoticeManager.getCompareLog(sysNoticeId, updDateTime);
		SysNoticeLog oldSysNoticeLog = new SysNoticeLog();
		SysNoticeLog newSysNoticeLog = new SysNoticeLog();
		if(list.size()==0){
			return "/sys/zx/sysZXNoticeLogDetail";
		}
		if(list.size()==1){
			oldSysNoticeLog = list.get(0);
			newSysNoticeLog = list.get(0);
		}
		if(list.size()>1){
			newSysNoticeLog = list.get(0);
			oldSysNoticeLog = list.get(1);
			
		}
		String oldStatus = oldSysNoticeLog.getStatus()==0?"未发布":"发布";
		String newStatus = newSysNoticeLog.getStatus()==0?"未发布":"发布";
		String oldUpdDatetime = DateUtil.dateTime(oldSysNoticeLog.getUpdDateTime());
		String newUpdDatetime = DateUtil.dateTime(newSysNoticeLog.getUpdDateTime());
		String newDatetime = DateUtil.dateTime(newSysNoticeLog.getDateTime());
		String oldDatetime = DateUtil.dateTime(oldSysNoticeLog.getDateTime());
		model.addAttribute("oldUpdDatetime", oldUpdDatetime);
		model.addAttribute("newUpdDatetime", newUpdDatetime);
		model.addAttribute("newDatetime", newDatetime);
		model.addAttribute("oldDatetime", oldDatetime);
		model.addAttribute("newSysNoticeLog", newSysNoticeLog);
		model.addAttribute("oldSysNoticeLog", oldSysNoticeLog);
		model.addAttribute("oldStatus", oldStatus);
		model.addAttribute("newStatus", newStatus);
		model.addAttribute("projId",projId);
		return "/sys/zx/sysZXNoticeLogDetail";
	}
	/**
	 * @category 获取维护记录列表
	 * @author zhouqi
	 * @date 2015年8月21日09:14:59
	 * @param void
	 * @return Pagination
	 */
	@RequestMapping("getSysZXNoticeLogList")
	@ResponseBody
	public Pagination getSysZXNoticeLogList(Pagination page){
		String sysNoticeId = request.getParameter("sysNoticeId");
	    String startPoint = request.getParameter("startPoint");
	    String endPoint = request.getParameter("endPoint");
	    if(StringUtils.isNoneBlank(startPoint)){
	    	page.getConditions().put("startPoint", startPoint);
	    }
	    if(StringUtils.isNoneBlank(endPoint)){
	    	page.getConditions().put("endPoint", endPoint);
	    }
	    if(StringUtils.isNoneBlank(sysNoticeId)){
	    	page.getConditions().put("sysNoticeId", sysNoticeId);
	    }
	    try{
	    	sysNoticeManager.getSysNoticeLogList(page);
	    	page.setSuccess(true);
	    }catch(Exception e){
	    	log.error("",e);
	    	page.setSuccess(false);
	    }
	    return page;
	}
	/**
	 * @category 获取维护记录详情
	 * @author zhouqi
	 * @date 2015年8月21日09:14:59
	 * @param SysNoticeLogId,model
	 * @return Pagination
	 */
	@RequestMapping("toSysZXNoticeLogDetial")
	public String toSysZXNoticeLogDetial(String sysNoticeLogId, Model model){
		SysNoticeLog sysNoticeLog = sysNoticeManager.getSysNoticeLogById(sysNoticeLogId);
		if(null != sysNoticeLog){
			model.addAttribute("sysNoticeLog",sysNoticeLog);
		}
		return "/sys/zx/sysZXNoticeLogDetial";
	}
	
	/**
	 * @category 获取公告详情
	 * @author zhouqi
	 * @date 2015年8月21日09:14:59
	 * @param SysNoticeLogId,model
	 * @return Pagination
	 */
	@RequestMapping("toSysZXNoticeDetial")
	public String toSysZXNoticeDetial(String sysNoticeId, Model model){
		SysNotice sysNotice = sysNoticeManager.getSysNoticeById(sysNoticeId);
		String projId = request.getParameter("projId");
		if(null != sysNotice){
			model.addAttribute("dateTime",ParseDate.parseFullFormat(sysNotice.getDateTime()));
			model.addAttribute("sysNotice",sysNotice);
		}
		if(StringUtils.isNotBlank(projId)){
			model.addAttribute("projId", projId);
		}
		return "/sys/zx/sysZXNoticeDetail";
	}
	
/*	public String toNoticeHas(){
		
	}*/
	
}
